package com.example.mvvmdemo.home.paging;

import android.annotation.SuppressLint;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.DiffUtil;

import com.example.mvvmdemo.utils.GsonUtil;

/**
 * created by tl
 * created at 2020/9/2
 */
public class DeviceComparator extends DiffUtil.ItemCallback<DeviceExceptionBean.ContentBean> {

    @Override
    public boolean areItemsTheSame(@NonNull DeviceExceptionBean.ContentBean oldItem, @NonNull DeviceExceptionBean.ContentBean newItem) {
        return oldItem.getId() == newItem.getId();
    }


    @Override
    public boolean areContentsTheSame(@NonNull DeviceExceptionBean.ContentBean oldItem, @NonNull DeviceExceptionBean.ContentBean newItem) {
        return GsonUtil.objectToString(oldItem).equals(GsonUtil.objectToString(newItem));
    }
}
